﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<InternshipManagement.Helpers.PaginatedList<InternshipManagement.Models.Semester>>" %>
<%@ Import Namespace="InternshipManagement.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Semester List
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% 
        
        ViewBag.SemesterOp = 1;
        Html.RenderPartial("SemesterMenu"); 
    %>
    <table class="list">
        <tr>
            <th>
                Name
            </th>
            <th style="width: 30%">
                Status
            </th>
            <th style="width: 240px;">
                Actions
            </th>
        </tr>
        <%
            bool odd = false;
            foreach (var item in Model)
            {
                odd = !odd;
        %>
        <tr class='<%=odd?"odd":"even" %>'>
            <td>
                <%=item.DisplayName%>
            </td>
            <td>
                <%=item.StatusDescription%>
            </td>
            <td>
                <div class="actions_menu" style="width:240px;">
                    <ul style="width:240px">
                        <% if (((List<int>)Session["UserPrivileges"]).Contains((int)UserPrivileges.EditSemester))
                           {%>
                        <li>
                            <%=Html.ActionLink("Edit", "Edit", new { id = item.SemesterID }, new { @class = "edit" })%>
                        </li>
                        <%} if (((List<int>)Session["UserPrivileges"]).Contains((int)UserPrivileges.DeleteSemester))
                           {%>
                        <li>
                            <%=Html.ActionLink("Delete", "Delete", new { Id = item.SemesterID }, new { @class = "delete" })%>
                        </li>
                        <%} if (((List<int>)Session["UserPrivileges"]).Contains((int)UserPrivileges.SetActiveSemester) && item.Status != "C")
                          { %>
                        <li>
                            <%= Html.ActionLink("Make Active", "Active", new { Id = item.SemesterID }, new { @class = "details" })%>
                        </li>
                        <%} %>
                    </ul>
                </div>
            </td>
        </tr>
        <% } %>
        <tr class='<%=odd?"even":"odd" %>'>
            <td colspan="3">
                <span class="prevpage">
                    <% if (Model.HasPreviousPage)
                       { %>
                    <%: Html.ActionLink("Previous Page",
                               "SemesterList", 
                               new { page=(Model.PageIndex-1) }) %>
                    <% } %>
                </span><span class="nextpage">
                    <% if (Model.HasNextPage)
                       { %>
                    <%: Html.ActionLink("Next Page",
                                                          "SemesterList", 
                               new { page=(Model.PageIndex+1) }) %>
                    <% } %>
                </span>
            </td>
        </tr>
    </table>
    <div id="dialog" title="Remove the semester?">
        Are you sure you want to remove this semester?
    </div>
</asp:Content>
